<template>
  <div class="vip-news" v-if="list.length">
    <div class="divider_header">
      <div class="titel">
        <div class="divider divider-l"></div>
        <h5>会员资讯</h5>
        <div class="divider divider-r"></div>
      </div>
      <div class="more" @click="$router.push('/dynamic/vip')">
        <span>更多会员资讯</span>
        <img src="@/assets/home_more.png" alt="" />
      </div>
    </div>

    <div class="content">
      <div
        v-if="list.length == 1"
        class="box"
        @click="jump(list[0].memberNewsId)"
      >
        <img
          v-if="list[0].newsCover"
          :src="$store.state.baseUrl + list[0].newsCover"
          alt=""
        />
        <img v-else src="@/assets/default.jpg" alt="" />
        <p class="describe">{{ list[0].newsTitle }}</p>
      </div>
      <div v-else class="list">
        <div class="box1" @click="jump(list[0].memberNewsId)">
          <img
            v-if="list[0].newsCover"
            :src="$store.state.baseUrl + list[0].newsCover"
            alt=""
          />
          <img v-else src="@/assets/default.jpg" alt="" />
          <p class="describe">{{ list[0].newsTitle }}</p>
        </div>
        <div class="box2">
          <ul>
            <li
              v-for="(item, index) in list.filter((item, index) => {
                return index != 0;
              })"
              :key="index"
              @mouseover="vipHover(index)"
              @mouseleave="hoverIndex = ''"
              @click="jump(item.memberNewsId)"
              :class="{ active: index === hoverIndex }"
            >
              <span
                :style="{
                  backgroundColor: index === hoverIndex ? '' : '#0b4e9e',
                }"
              ></span>
              <div>
                <p
                  class="titel"
                  :style="{ color: index === hoverIndex ? '#0B4E9E' : '' }"
                >
                  {{ item.newsTitle }}
                </p>
                <p class="describe">{{ item.newsTitle }}</p>
                <p class="time">{{ item.publishTime | formatTime }}</p>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>
<script >
export default {
  props: ["list"],
  data() {
    return {
      hoverIndex: "",
    };
  },
  methods: {
    vipHover(index) {
      this.hoverIndex = index;
    },
    jump(id) {
      this.$router.push(`/vipDetail/${id}`);
    },
  },
};
</script>
<style lang="less">
.vip-news {
  width: 100%;
  height: 663px;
  // background-color: rgba(0, 0, 0, 0.1);
  background-image: url("..//assets/home_bg.jpg");
  padding: 78px 0 96px 0;
  box-sizing: border-box;
  margin: 0 auto;
  .content {
    width: 75%;
    height: 345px;
    margin: 0 auto;
    .box {
      width: 100%;
      height: 100%;
      // background-color: red;
      cursor: pointer;
      position: relative;
      img {
        width: 100%;
        height: 100%;
      }
      p {
        max-width: 100%;
        position: absolute;
        padding: 0 24px;
        box-sizing: border-box;
        bottom: 13px;
        color: rgba(255, 255, 255, 0.85);
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
    .list {
      width: 100%;
      display: flex;
      .box1 {
        min-width: 48%;
        height: 345px;
        // background-color: red;
        margin-right: 10px;
        cursor: pointer;
        position: relative;
        img {
          width: 100%;
          height: 100%;
        }
        p {
          max-width: 100%;
          position: absolute;
          padding: 0 24px;
          box-sizing: border-box;
          bottom: 13px;
          color: rgba(255, 255, 255, 0.85);
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
      }
      .box2 {
        flex: auto;

        ul {
          display: flex;
          flex-wrap: wrap;
          width: 100%;
          height: 345px;
          // overflow: hidden;
          li {
            width: 48%;
            height: 80px;
            display: flex;
            margin-bottom: 10px;
            cursor: pointer;
            &:nth-child(odd) {
              margin-right: 10px;
            }
            &:nth-child(1) {
              margin-bottom: 0;
            }

            span {
              min-width: 12px;
              height: 12px;
              margin: 0 10px;
              margin-top: 10px;
              display: inline-block;
              border-radius: 50%;
            }
            div {
              flex: auto;
              max-width: 436px;
              p {
                width: 100%;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                margin-bottom: 6px;
                color: #666;
              }
              .titel {
                margin-top: 5px;
                font-size: 16px;
                color: #333;
              }
              .describe {
                // font-size: 14px;
              }
              .time {
                font-size: 14px;
              }
            }
          }
          .active {
            position: relative;
            top: -3px;
            background-color: #fff;
            border-radius: 2px;
            box-shadow: 2px 2px 8px 0px rgba(5, 33, 67, 0.4);
          }
        }
      }
    }
  }
}
</style>